regression <- function(data) {

  # initial binding of globals
  `%>%` <- magrittr::`%>%`
  election <- term <- estimate <- conf_low <- conf_high <- NULL
  conf.low <- conf.high <- relative_date <- NULL

  # linear regression swd on win_cabinet by election
  results <- data %>%
    dplyr::filter(relative_date > 0) %>%
    dplyr::group_by(election) %>%
    tidyr::nest() %>%
    dplyr::mutate(data = purrr::map(data, function(x) {
      result <- broom::tidy(
        glm(swd ~ win_cabinet, data = x, family = gaussian()),
        conf.int = TRUE, conf.level = .95
      )
      result <- dplyr::filter(.data = result, term == "win_cabinet")
    })) %>%
    tidyr::unnest(cols = data) %>%
    dplyr::select(
      election, estimate, conf_low = conf.low, conf_high = conf.high
    ) %>%
    dplyr::ungroup()

  # plot theme
  ggplot2::theme_set(new = ggthemes::theme_wsj(base_size = 9))

  # plot
  ggplot2::ggplot(
    data = results, mapping = ggplot2::aes(
      xmin = conf_low, xmax = conf_high, y = election
    )
  ) +
    ggplot2::geom_linerange() +
    ggplot2::geom_point(mapping = ggplot2::aes(y = election, x = estimate)) +
    ggplot2::geom_vline(xintercept = 0, lty = "dashed") +
    ggplot2::scale_x_continuous(
      labels = seq(from = - .1, to = .6, by = .1),
      breaks = seq(from = - .1, to = .6, by = .1)
    ) +
    ggplot2::labs(
      x = "Normalized Effect size",
      subtitle = "Satisfaction with Democracy on Electoral Winner-Status"
    ) +
    ggplot2::theme(
      axis.title.x = ggplot2::element_text(vjust = -1, size = 11),
      axis.text.y = ggplot2::element_text(size = 9, face = "plain"),
      axis.text.x = ggplot2::element_text(size = 9, face = "plain"),
      plot.title = ggplot2::element_text(hjust = +1.8, size = 15),
      plot.subtitle = ggplot2::element_text(hjust = + 1.1, size = 11),
      plot.caption = ggplot2::element_text(size = 10, vjust = -3),
      plot.caption.position = "plot",
      panel.background = ggplot2::element_rect(fill = "white"),
      plot.background = ggplot2::element_rect(fill = "white")
    )

  ggplot2::ggsave(
    filename = "./figures/figure_2.png",
    device = "png",
    width = 14,
    height = 8,
    units = "cm",
    dpi = 600
  )

}
